﻿@{
    ViewBag.Title = "库存台账";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<style type="text/css">
    .tool_c {
        padding: 10px 0;
    }

    .btn-group {
        padding: 0 10px 0 0;
    }

    .grid_list_2_c {
        overflow: hidden;
    }

        .grid_list_2_c .frozen-bdiv {
            top: 34px !important;
        }

        .grid_list_2_c .frozen-div {
            height: 3em !important;
        }

        .grid_list_2_c .ui-jqgrid-hdiv {
            width: 1900px !important;
            background-color: transparent !important;
        }

        .grid_list_2_c .ui-jqgrid-bdiv {
            width: 1900px !important;
            background-color: transparent !important;
        }

        .grid_list_2_c .ui-jqgrid-btable {
            background-color: #fff !important;
        }

    .btn-group:last-child a.btn:first-child {
        margin: 0 0.5em 0 0 !important;
    }
</style>
<script>
    $(function () {
        initControl();
        gridList();

        $("#txtStartDate2").val(new Date().format("yyyy-MM-01"));

        $("#txtEndDate2").val(new Date().format("yyyy-MM-{0}".format(getMaxDay())));
    });

    var getMaxDay = function () {
        var r = 31, m = new Date().getMonth() + 1, y = new Date().getFullYear(), sec = [4, 6, 9, 11];
        //能被4整除但不能被100整除，或能被400整除的年份
        2 == m && (r = (((0 == y % 4 && 0 != y % 100) || 0 == y % 400) ? 29 : 28));

        sec.indexOf(m) && (m = 30);

        return r;
    }

    function initControl() {
        var myLayout = $('#layout').layout({ resizeable: false });
        $('select').bindSelect();
        //供货单位名称
        $(".txt_FProCompanyName").bindSelect({
            url: "/BaseData/ZSJ_B1_GH_SI/GetGridJson?isProduct=1",
            id: "UnitNO",
            text: "UnitNOShortName"
        });
        //仓库基础数据
        $("#FStoreNO").bindSelect({
            url: "/BaseData/ZSJ_B1_GH_SI/GetStockInfo",
            id: "FStoreNO",
            text: "UnitNOShortName"
        });

        //显示台账日期
        var keyValue = $.request("keyValue");
        $.ajax({
            url: "/WareHouse/EnterWareHouse/GetInfoDocumentNum",
            data: { keyValue: keyValue },
            dataType: "json",
            async: false,
            success: function (data) {
                $("#form1").formSerialize(data);
                //var dataa =  data.Substring(0, 4);
                //alert("a");
                $("#FAccountDate").val(data);
            }
        });


        //零件分类
        $(".txt_FTypeName").bindSelect({//FClassNO ='01'
            url: "/VBaseData/V_BUS_SJ_Dictionary/GetSJ_DictionaryEntity",
            id: "FTypeNO",
            text: "UnitTypeNoName",
        });
        //发生方式
        $(".FTypeNO").bindSelect({//FClassNO ='01'
            url: "/VBaseData/V_BUS_SJ_Dictionary/GetSJ_DictionaryEntityByClassNo?classNo=03",
            id: "FTypeNO",
            text: "UnitTypeNoName",
        });
        //发生单位
        $("#FHappenCompanyNO2").bindSelect({
            url: "/VBaseData/V_BUS_SJ_Dictionary/GetOccurrenceUnit",
            id: "UnitNO",
            text: "UnitShortName",
        });


        //批次查询 btn_search1
        $("#btn_search1").on("click", function () {
            var $gridList1 = $("#gridList1");

            var conn1 = {
                "FDocuNO": $("#FDocuNO").val(),
                "FVoucherNo": $("#FVoucherNo").val(),
                "FHappenCompanyNO": $("#FHappenCompanyNO").val(),
                "FProductionNO": $("#FProductionNO").val(),
                "FProductionName": $("#FProductionName").val(),
                "FProCompanyNO": $("#FProCompanyNO").val(),
                "FProductionTypeNO": $("#FProductionTypeNO").val(),
                "FStoreNO": $("#FStoreNO").val()
            };

            $gridList1.jqGrid('setGridParam', {
                postData: conn1,
            }).trigger('reloadGrid');
        });
        //单据查询 btn_search2
        $("#btn_search2").on("click", function () {
            var $gridList2 = $("#gridList2");

            var conn2 = {
                "FDocuNO": $("#FDocuNO2").val(),
                "FVoucherNo": $("#FVoucherNo2").val(),
                "FTypeNO": $("#FTypeNO2").val(),
                "FHappenComNO": $("#FHappenCompanyNO2").val(),
                "startDate": $("#txtStartDate2").val(),
                "endDate": $("#txtEndDate2").val(),
                "FProductionNO": $("#FProductionNO2").val(),
                "FProductionName": $("#FProductionName2").val(),
                "FProCompanyNO": $("#FProCompanyNO2").val()
            };

            $gridList2.jqGrid('setGridParam', {
                postData: conn2,
            }).trigger('reloadGrid');
        });

    }
    function gridList() {
        //FDocuNO FVoucherNo FHappenCompanyNO FProductionNO FProductionName FProCompanyNO FProductionTypeNO
        var conn1 = {
            "FDocuNO": $("#FDocuNO").val(),
            "FVoucherNo": $("#FVoucherNo").val(),
            "FHappenCompanyNO": $("#FHappenCompanyNO").val(),
            "FProductionNO": $("#FProductionNO").val(),
            "FProductionName": $("#FProductionName").val(),
            "FProCompanyNO": $("#FProCompanyNO").val(),
            "FProductionTypeNO": $("#FProductionTypeNO").val(),
            "FStoreNO": $("#FStoreNO").val()
        };
        var $gridList1 = $("#gridList1");
        $gridList1.dataGridForJson({
            url: "/VBaseData/V_CPK_A1_BB_StoProStockCata_RB/GetGridBatchStoreStat",
            postData: conn1,
            height: $(window).height() - 220,
            colModel: [
                { label: '单据编号', name: 'FDocuNO', width: 120, align: 'center', },
                { label: '来料单位', name: 'FHappenCompanyNO', width: 120, align: 'center', },
                { label: "来料单位名称", name: 'FHappenCompanyName', width: 160, align: 'left', },
                { label: '零件编号', name: 'FProductionNO', width: 120, align: 'left', },
                { label: '零件名称', name: 'FProductionName', width: 160, align: 'left' },
                { label: '入库数量', name: 'FQuantity_RK', width: 80, align: 'right' },
                { label: '出库数量', name: 'FQuantity_CK', width: 80, align: 'right' },
                { label: '当前库存', name: 'FQuantity_RK_FQuantity_CK', width: 80, align: 'right' },
                { label: '仓库编号', name: 'FStoreNO', width: 60, align: 'left' },
                { label: '库位编号', name: 'FStoreSetNO', width: 100, align: 'left' },
                { label: '制造单位', name: 'FProCompanyNO', width: 120, align: 'center' },
                { label: '制造单位名称', name: 'FProCompanyName', width: 160, align: 'left' },
                { label: '零件分类名称', name: 'FProductionTypeName', width: 100, align: 'center' },
                { label: '输入日期', name: 'FCreateDate', width: 80, align: 'center' },
                { label: '输入时间', name: 'FCreateTime', width: 80, align: 'center' },
                 { label: ' ', name: ' ', width: ($(window).width() - 1720), align: 'left', sortable: false }
            ],
            pager: "#gridPager1",
            sortname: 'FProductionNO,FProCompanyNO',
            sortorder:"asc",
            viewrecords: true,
            //multiselect: true,
            rownumWidth: 50,
            onSelectRow: function (rowId) {
                rowData = $gridList1.jqGrid('getRowData', rowId);
                index = rowId;
                $.each(rowData, function (key, value) {
                    $("#txt" + key).val(value);
                });
            }
        });
        $gridList1.jqGrid('setLabel', 0, '序号', 'rowNumberHeaderStyle');
        //$gridList1.jqGrid('setFrozenColumns');

        //FDocuNO2 FVoucherNo2 FTypeNO2 FHappenCompanyNO2 txtStartDate2 txtEndDate2  FProductionNO2 FProductionName2 FProCompanyNO2 
        var conn2 = {
            "FDocuNO": $("#FDocuNO2").val(),
            "FVoucherNo": $("#FVoucherNo2").val(),
            "FTypeNO": $("#FTypeNO2").val(),
            "FHappenComNO": $("#FHappenCompanyNO2").val(),
            "startDate": $("#txtStartDate2").val(),
            "endDate": $("#txtEndDate2").val(),
            "FProductionNO": $("#FProductionNO2").val(),
            "FProductionName": $("#FProductionName2").val(),
            "FProCompanyNO": $("#FProCompanyNO2").val()
        };

        var $gridList2 = $("#gridList2");



        $gridList2.dataGridForJson({
            url: "/VBaseData/V_CPK_A1_BB_StoProStockCata_RB/GetGridBillQueryStat",
            height: $(window).height() - 220,
            postData: conn2,
            colModel: [
            { label: '发生方式', name: '', width: 120, align: 'left', frozen: true },
            { label: '单据编号', name: 'FDocuNO', width: 120, align: 'left', frozen: true },
            { label: "来料单位", name: "FHappenComNO", width: 120, align: 'center', frozen: true },
            { label: '来料单位名称', name: 'FHappenComName', width: 160, align: 'left', frozen: true },
            { label: '单据日期', name: 'FCurDate', width: 120, align: 'center', frozen: true },
            { label: '零件编号', name: 'FProductionNO', width: 120, align: 'left', frozen: true },
            { label: '零件名称', name: 'FProductionName', width: 160, align: 'left' },
            { label: "批次号", name: "FBatchNo", width: 120, align: 'left' },
            { label: '开票数量', name: 'FQuantity_KP', width: 100, align: 'right' },
            { label: '实际数量', name: 'Fquantity', width: 100, align: 'right' },
            { label: '仓库编号', name: 'FStoreNO', width: 120, align: 'left' },
            { label: '库位编号', name: 'FStoreSetNO', width: 120, align: 'left' },
            { label: "容器编号", name: "FContainerNO", width: 120, align: 'left' },
            { label: '容器名称', name: 'FContainerName', width: 160, align: 'left' },
            { label: '容器数量', name: 'FContainerQuantity', width: 100, align: 'right' },
            { label: '实际装箱', name: 'FFactContent', width: 100, align: 'right' },
            { label: '标准装箱', name: 'Fcontent', width: 100, align: 'right' },
            { label: "托盘编号", name: "FPalletNO", width: 120, align: 'left' },
            { label: '托盘数量', name: 'FPalletQuantity', width: 100, align: 'right' },
            { label: '实际容量', name: 'FPalletFactContent', width: 80, align: 'right' },
            { label: '标准容量', name: 'FPalletContent', width: 80, align: 'right' },
            { label: '凭证编号', name: 'Fcredence', width: 120, align: 'left' },
            { label: "制造单位", name: "FProCompanyNO", width: 120, align: 'center' },
            { label: '制造单位名称', name: 'FProCompanyName', width: 160, align: 'left' },
            { label: '零件分类', name: 'FProductionTypeName', width: 100, align: 'left' },
            { label: '操作人员', name: 'FProductionNOFCreateBy', width: 80, align: 'left' },
            { label: '输入日期', name: 'FCreateDate', width: 80, align: 'center' },
            { label: "输入时间", name: "FCreateTime", width: 80, align: 'center' },
            { label: '审核人员', name: 'FAuditingBy', width: 80, align: 'left' },
            { label: '审核日期', name: 'FAuditingDate', width: 80, align: 'center' },
            { label: '审核时间', name: 'FAuditingTime', width: 80, align: 'center' }

            ],
            pager: "#gridPager2",
            sortname: 'FCurDate,FProductionNO,FProCompanyNO',
            sortorder: "DESC",
            viewrecords: true,
            rownumWidth: 50,
            onSelectRow: function (rowId) {
                rowData = $gridList2.jqGrid('getRowData', rowId);
                index = rowId;
                $.each(rowData, function (key, value) {
                    $("#txt" + key).val(value);
                });
            }
        });
        $gridList2.jqGrid('setLabel', 0, '序号', 'rowNumberHeaderStyle');
        $gridList2.jqGrid('setFrozenColumns');
    }


</script>
<div class="layout" id="layout" style="height: 100%; width: 100%;">
    <div id="showTable" class="ui-layout-center ">
        <div style="padding: 5px 5px;" class="line-table ">
            <ul id="myTab" class="nav nav-tabs" style="">
                <li class="active"><a href="#InputStatisticsInfo" data-toggle="tab">库存明细</a></li>
                <li><a href="#BatchInfoInfo" data-toggle="tab">批次库存</a></li>
                <li><a href="#BillInfoInfo" data-toggle="tab">单据档案</a></li>
            </ul>
            <div id="myTabContent" class="tab-content">
                <div class="tab-pane fade in active" id="InputStatisticsInfo">
                    <iframe name="target_win" width="100%" height="715px" frameborder="0" scrolling="no" src="/WareHouse/EnterWareHouse/StatisticLedger"></iframe>
                </div>
                <div class="tab-pane fade" id="BatchInfoInfo">
                    <div class="tool_c">
                        <div class="btn-group">
                            &nbsp;单据编号<br />
                            <input id="FDocuNO" name="" placeholder="" type="text" class="form-control required" />
                        </div>
                        <div class="btn-group input-width-185">
                            &nbsp;来料单位<br />
                            <select id="FHappenCompanyNO" name="" class="form-control txt_FProCompanyName">
                                <option value="">==请选择==</option>
                            </select>
                        </div>
                        <div class="btn-group">
                            &nbsp;零件编号<br />
                            <input id="FProductionNO" name="" placeholder="" type="text" class="form-control required input-width-105" />
                        </div>
                        <div class="btn-group">
                            &nbsp;零件名称<br />
                            <input id="FProductionName" name="" placeholder="" type="text" class="form-control required input-width-140" />
                        </div>
                        <div class="btn-group input-width-105">
                            &nbsp;仓库<br />
                            <select id="FStoreNO" name="" class="form-control">
                                <option value="">==请选择==</option>
                            </select>
                        </div>
                        <div class="btn-group input-width-185">
                            &nbsp;制造单位<br />
                            <select class="txt_FProCompanyName" id="FProCompanyNO" name="">
                                <option value="">==请选择==</option>
                            </select>
                        </div>
                        <div class="btn-group input-width-105" style="margin-top: 0px;">
                            &nbsp;零件分类<br />
                            <select class="txt_FTypeName" id="FProductionTypeNO" name="">
                                <option value="" style="width: 80px;">==请选择==</option>
                            </select>
                        </div>
                        <div class="btn-group">
                            <a id="btn_search1" class="btn btn-primary center-block"><span class="glyphicon glyphicon-search"></span>查询</a>
                            <a class="btn btn-primary center-block" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span>&nbsp刷新</a>
                            <a class="btn btn-primary center-block" onclick=""><span class="glyphicon glyphicon-refresh"></span>&nbsp计算</a>
                            <a class="btn btn-primary center-block" onclick="btn_Print()"><span class="glyphicon glyphicon-print"></span>&nbsp打印</a>
                            <a class="btn btn-primary center-block" onclick="btn_Excel()"><span class="glyphicon glyphicon-download"></span>&nbsp导出</a>
                        </div>
                    </div>
                    <div class="grid_list_1_c" style="margin-top: 5px;">
                        <table id="gridList1"></table>
                        <div id="gridPager1"></div>
                    </div>
                </div>
                <div class="tab-pane fade" id="BillInfoInfo">
                    <div class="tool_c">
                        <div class="btn-group input-width-105">
                            &nbsp;发生方式<br />
                            <select id="FTypeNO2" name="" class="form-control FTypeNO">
                                <option value="">==请选择==</option>
                            </select>
                        </div>
                        <div class="btn-group">
                            &nbsp;单据编号<br />
                            <input id="FDocuNO2" name="" placeholder="" type="text" class="form-control required input-width-105" />
                        </div>
                        <div class="btn-group input-width-185">
                            &nbsp;来料单位<br />
                            <select id="FHappenCompanyNO2" name="" class="form-control">
                                <option value="">==请选择==</option>
                            </select>
                        </div>
                        <div class="btn-group">
                            &nbsp;单据日期<br />
                            <input id="txtStartDate2" name="" placeholder="" type="text" class="form-control required input-width-80" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', isShowClear: false });" />
                            到
                        <input id="txtEndDate2" name="" placeholder="" type="text" class="form-control required input-width-80" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd',isShowClear: false });" />
                        </div>
                        <div class="btn-group">
                            &nbsp;零件编号<br />
                            <input id="FProductionNO2" name="" placeholder="" type="text" class="form-control required input-width-105" />
                        </div>
                        <div class="btn-group">
                            &nbsp;零件名称<br />
                            <input id="FProductionName2" name="" placeholder="" type="text" class="form-control required input-width-105" />
                        </div>
                        <div class="btn-group">
                            &nbsp;凭证编号<br />
                            <input id="FVoucherNo2" name="" placeholder="" type="text" class="form-control required" />
                        </div>
                        <div class="btn-group input-width-105" style="margin-top: 0px;">
                            <div>
                                &nbsp;制造单位<br />
                                <select class="txt_FProCompanyName" id="FProCompanyNO2" name="">
                                    <option value="">==请选择==</option>
                                </select>
                            </div>
                        </div>
                        <div class="btn-group">
                            <div class="input-width-105">
                                &nbsp;零件分类<br />
                                <select class="txt_FTypeName" id="FProductionTypeNO2" name="">
                                    <option value="" style="width: 80px;">==请选择==</option>
                                </select>
                                &nbsp;
                            </div>
                        </div>
                        <div class="btn-group">
                            <a id="btn_search2" class="btn btn-primary center-block" onclick=""><span class="glyphicon glyphicon-search"></span>查询</a>
                            <a class="btn btn-primary center-block" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span>&nbsp刷新</a>
                            <a class="btn btn-primary center-block" onclick="btn_Print()"><span class="glyphicon glyphicon-print"></span>&nbsp打印</a>
                            <a class="btn btn-primary center-block" onclick="btn_Excel()"><span class="glyphicon glyphicon-download"></span>&nbsp导出</a>
                        </div>
                    </div>
                    <div class="grid_list_2_c" style="margin-top: 5px; display: block;">
                        <table id="gridList2" style="width: 100%;"></table>
                        <div id="gridPager2"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
